// components/login/login.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    isLoading:false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    login(){
      this.setData({
        isLoading:true
      })
      // console.log(e);
      wx.getUserProfile({
        desc:'获取头像，名称信息',
        success:(res) => {
          console.log(res);
          let avatarUrl = res.userInfo.avatarUrl,
          nickName = res.userInfo.nickName
  
          // let 
          wx.cloud.callFunction({
            name:"login"
          }).then((res) => {
            console.log(res);
            if(res.result.openid){
              let parm = {
                openid:res.result.openid,
                avatarUrl,
                nickName
              }
              wx.setStorageSync("data",JSON.stringify(parm))
              this.triggerEvent('logined',{login:true})
            }
          })
        }
      })
    },
  

  }
})
